package com.event.starter.config;

import com.event.common.face.IEventHandle;
import com.event.core.context.EventContext;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;

/**
 * @Description 自动配置JPA
 * @Author Bing
 * @Date 2024/10/16 14:58
 */
@Configuration
@ConditionalOnProperty(name = "config.jpa.enable", havingValue = "true")
public class AutoJpaConfig {
    // 事件处理器
    @Resource
    private IEventHandle eventHandle;

    @Bean
    @ConditionalOnMissingBean(EventContext.class)
    public EventContext eventContext(){
        return new EventContext(eventHandle);
    }
}